<template>
	<view>
		<view class="header"></view>
		<view class="hp" @click="goUserDetail">
			<image src="../../static/logo.png"></image>
			<view class="name">
				{{ name }}
			</view>
			<view class="icon-info" @click.stop="showModal"></view>
			<view class="icon-qr_code" @click="go_qr"></view>
		</view>
		<view class="body">
			<view class="position">
				<view class="icon-user w"></view>
				<text>{{ position }}</text>
			</view>


			<view v-for="(item, index) in navs" :key="index" @click="navItemClick(item.path)">
				<view :class="item.icon"></view>
				<text>{{ item.title }}</text>
				<text class="icon-cheveron-right"></text>
			</view>
			
			<view>
				<view class="icon-bubbles3 w"></view>
				<uni-link href="https://docs.qq.com/form/page/DWFBmSUV0R1RHc25n?_w_tencentdocx_form=1#/fill" text="帮助反馈" showUnderLine=false color="#333" fontSize="50rpx" ></uni-link>
				<text class="icon-cheveron-right"></text>
			</view>
			
			<view @click="gosetting">
				<view class="icon-cog w"></view>
				<text>设置</text>
				<text class="icon-cheveron-right"></text>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		getUserById
	} from '../../api/user.js'
	export default {
		data() {
			return {
				navs: [{
						icon: 'icon-user-check w',
						title: '信息绑定',
						path: '/pages/bind/bind'
					},
					{
						icon: 'icon-qq w',
						title: '关于软件',
						path: '/pages/regards/regards'
					}
				],
				imgUrl: '../../static/logo.png'
			}
		},
		onLoad() {

		},
		computed: {
			position() {
				if (this.$store.state.userInfo.role === 3) return 'Student'
				if (this.$store.state.userInfo.role === 2) return 'Teacher'
				if (this.$store.state.userInfo.role === 1) return 'Super Manager'
			},
			name() {
				return this.$store.state.userInfo.username
			}
		},
		methods: {
			navItemClick(url) {
				uni.navigateTo({
					url
				})
			},
			go_qr() {
				uni.navigateTo({
					url: '/pages/qr-code/qr-code'
				})
			},
			gosetting(){
				uni.navigateTo({
					url:"/pages/setting/setting"
				})
			},
			goUserDetail(){
				uni.navigateTo({
					url:'/pages/user-detail/user-detail'
				})
			},
			showModal(){
				uni.showModal({
				    title: '实时通知',
				    content: '实时通知',
				    success: function (res) {
				        if (res.confirm) {
				            console.log('用户点击确定');
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>
<style lang="less">
	page {
		background-color: #fafafa;
	}

	.header {
		/* 联集 1 */
		position: absolute;
		left: 0px;
		top: 0px;
		width: 750rpx;
		height: 420rpx;
		border-radius: 50% / 10%;
		margin-top: -20rpx;
		background: url(https://img0.baidu.com/it/u=1268231363,465558292&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=500);
	}

	.hp {
		/* 矩形 7 */
		position: absolute;
		left: 24rpx;
		top: 360rpx;
		width: 702rpx;
		height: 146rpx;
		border-radius: 24rpx;
		background: #FFFFFF;

		image {
			/* 圆形 2 */
			position: absolute;
			left: 290rpx;
			top: -61rpx;
			width: 122rpx;
			height: 122rpx;
			border-radius: 50%;
		}
		
		.icon-info {
			position: absolute;
			top: 50rpx;
			left: 30rpx;
			
			&::before {
				font-size: 42rpx;
			}
		}
		
		.icon-qr_code {
			position: absolute;
			top: 50rpx;
			right: 30rpx;

			&::before {
				font-size: 42rpx;
			}
		}

		.name {
			margin-top: 70rpx;
			text-align: center;
			font-family: SourceHanSansCN-Bold;
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
		}
	}

	.body {
		/* 矩形 8 */
		position: absolute;
		left: 24rpx;
		top: 560rpx;
		width: 702rpx;
		height: 540rpx;
		padding-left: 20rpx;
		border-radius: 12px;
		background: #FFFFFF;

		>view {
			position: relative;
			height: 108rpx;
			color: #474747;

			text {
				margin-left: 30rpx;
				line-height: 108rpx;
			}
			
			.uni-link {
				position: absolute;
				top: 0;
				left: -50rpx;
				width: 100%;
				height: 100%;
				padding-left: 110rpx;
			}
			.w {
				position: relative;
				display: inline-block;
				vertical-align: middle;
				width: 60rpx;
				height: 60rpx;
				margin-top: -6rpx;
				border-radius: 50%;

				&::before {
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%, -50%);
					color: #fff;
					font-size: 14px;
				}

				&.icon-user {
					background-color: #4809e8;
				}

				&.icon-user-check {
					background-color: #89de50;
				}

				&.icon-qq {
					background-color: #1e80f9;
				}

				&.icon-bubbles3 {
					background-color: #108ce4;
					margin-top: 20rpx;
				}

				&.icon-cog {
					background-color: #9b4df4;
				}
			}

			.icon-cheveron-right {
				position: absolute;
				right: 15rpx;
			}
		}
	}
</style>
